AM_SRCS := common/trm.c \
           common/ioe.c \
           common/-input.c \
           common/-timer.c \
           common/-video.c \
           arch/cte.c \
           arch/trap.S \
           arch/vme.c \
           arch/boot/start.S

LD_SCRIPT := $(RISCV_AM_HOME)/src/arch/boot/loader.ld

# ifdef mainargs
# MAINARGS = -a $(mainargs)
# endif
# NEMU_ARGS = -b $(MAINARGS) -l $(shell dirname $(BINARY))/nemu-log.txt $(BINARY).bin

image:
	@echo + LD "->" $(BINARY_REL).elf
	@$(LD) $(LDFLAGS) --gc-sections -T $(LD_SCRIPT) -e _start -o $(BINARY).elf $(LINK_FILES)
	@$(OBJDUMP) -d $(BINARY).elf > $(BINARY).txt
	@echo + OBJCOPY "->" $(BINARY_REL).bin
	@$(OBJCOPY) -S --set-section-flags .bss=alloc,contents -O binary $(BINARY).elf $(BINARY).bin

# run:
# 	$(MAKE) -C $(NEMU_HOME) ISA=$(ISA) run ARGS="$(NEMU_ARGS)"

